//
//  HWButton.m
//  HuiWenMovie
//
//  Created by ios on 15/7/19.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "HWButton.h"

@implementation HWButton



- (id)initWithFrame:(CGRect)frame AndImageName:(NSString *)imageName WithTitleName:(NSString *)text
{
    self = [super initWithFrame:frame];
    
    if(self)
    {
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.imageView.image = [UIImage imageNamed:imageName];
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        self.title = [[UILabel alloc]initWithFrame:CGRectZero];
        self.title.text = text;
        self.title.textAlignment = NSTextAlignmentCenter;
        self.title.font = [UIFont systemFontOfSize:11];
        
        [self addSubview:self.imageView];
        [self addSubview:self.title];
    
    }

    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imageView.frame = CGRectMake((self.frame.size.width-20)/2, 5, 20, 20);

    self.title.frame = CGRectMake(0, CGRectGetMaxY(self.imageView.frame), CGRectGetWidth(self.frame), 20);

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
